package com.yanqu.road.server.cmd.cross.marriage.world;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.marriage.CrossMarriageProto;
import com.yanqu.road.pb.marriage.MarriageProto;
import com.yanqu.road.server.cmd.base.AbstractServerCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.marriage.MarriageMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_WORLD_MARRIAGE_PUBLISH_RESP, desc = "跨服联姻发布响应（跨服商会分组）")
public class CrossWorldMarriagePublishRespCmd extends AbstractServerCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CrossMarriageProto.CrossMarriageApplyPublishCrossRespMsg reqMsg = CrossMarriageProto.CrossMarriageApplyPublishCrossRespMsg.parseFrom(packet.getBytes());
        GamePlayer player = GamePlayerMgr.getPlayer(packet.getPlayerId());
        if(null != player) {
            ret = MarriageMgr.crossWorldMarriagePublishResponse(player, reqMsg);
            MarriageProto.MarriageApplyPublishRespMsg.Builder respMsg = MarriageProto.MarriageApplyPublishRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_MARRIAGE_APPLY_PUBLISH, respMsg);
        }

    }

    @Override
    public void sendData(YanQuMessage packet) throws Exception {

    }
}
